chrome.devtools.panels.create('MyPanel', 'icon.png', 'panel.html', null)

var backgroundPageConnection = chrome.runtime.connect({
    name: "devtools-page"
})

backgroundPageConnection.onMessage.addListener(function (params) {

})

chrome.devtools.network.onRequestFinished.addListener(
    function (request) {

        request.getContent(function (content, encoding) {
            //按课程代码获取内容
            if (request.request.url.indexOf('getContentByCourseCode') !== -1) {
                chrome.runtime.sendMessage({
                    cmd: 'getContentByCourseCode',
                    data: content
                })
            }
            //按课程代码获取内容状态
            if (request.request.url.indexOf('getContentStatusByCourseCode') !== -1) {
                chrome.runtime.sendMessage({
                    cmd: 'getContentStatusByCourseCode',
                    data: content
                })
            }
        })
    }
)